home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-06 / an102x.zip / ADDRESS.C < prev    next >
C/C++ Source or Header  |  1991-04-09  |  2KB  |  92 lines

  1. /*****************************************************************************
  2. * ADDRESS.C
  3. *
  4. * 90-12-27 Matt Hagen, Novell, Inc.
  5. *****************************************************************************/
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. #define BYTE unsigned char
  11. #define WORD unsigned short
  12. #define LONG unsigned long
  13.  
  14. typedef struct
  15. {
  16.     BYTE inUse;
  17.     BYTE order;
  18.     BYTE net[4];
  19.     BYTE node[6];
  20.     BYTE socket[2];
  21.     BYTE timeout[2];
  22.     BYTE immedAddr[6];
  23.     BYTE sequence;
  24.     BYTE connectionNum;
  25.     BYTE connectionStatus;
  26.     BYTE maxTimeout[2];
  27.     BYTE reserved[5];
  28. }ConnIDTable;
  29.  
  30. extern int GetConnectionIDTableEntry(
  31.     WORD connID,
  32.     ConnIDTable *entry);
  33.  
  34. int GetServerAddress(
  35.     WORD connID,
  36.     BYTE *net,
  37.     BYTE *node,
  38.     BYTE *immediate);
  39.  
  40. /*****************************************************************************
  41. * main
  42. *****************************************************************************/
  43.  
  44. main()
  45. {
  46.     WORD c;
  47.     BYTE net[4];
  48.     BYTE node[6];
  49.     BYTE immediate[6];
  50.  
  51.     for(c=1;c<9;c++)
  52.     {
  53.         GetServerAddress(c,net,node,immediate);
  54.         printf("Slot %d %.2X%.2X%.2X%.2X  ",c,net[0],net[1],net[2],net[3]);
  55.         printf("%.2X%.2X%.2X%.2X%.2X%.2X  ",node[0],node[1],node[2],node[3],node[4],node[5]);
  56.         printf("%.2X%.2X%.2X%.2X%.2X%.2X\n",immediate[0],immediate[1],immediate[2],immediate[3],immediate[4],immediate[5]);
  57.     }
  58.  
  59.     return(0);
  60. }
  61.  
  62. /*****************************************************************************
  63. * GetServerAddress
  64. *
  65. * connID is an index (1..8) into the table.  net points to a four-byte buffer
  66. * for the server's network address.  node points to a 6-byte buffer for the
  67. * server's node address.  immediate points to a 6-byte buffer for the node
  68. * address of the router that routes packets from the client to the server.
  69. * This routine returns 0 for successful and -1 if connID is an invalid number.
  70. *****************************************************************************/
  71.  
  72. int GetServerAddress(
  73.     WORD connID,
  74.     BYTE *net,
  75.     BYTE *node,
  76.     BYTE *immediate)
  77. {
  78.     ConnIDTable e;
  79.  
  80.     if(GetConnectionIDTableEntry(connID,&e)!=0)
  81.         return(-1);
  82.  
  83.     memmove(net,&e.net,4);
  84.     memmove(node,&e.node,6);
  85.     memmove(immediate,&e.immedAddr,6);
  86.  
  87.     return(0);
  88. }
  89.  
  90. /****************************************************************************/
  91. /****************************************************************************/
  92.